﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace IceDog.SmallProject.CodeConvert
{
    class Program
    {
        static void Main(string[] args)
        {
            TextCodeGuessHelper.RegisterMoreEncoding();

            var builder = new StringBuilder();
            var filePath = "test-file/";
#if DEBUG
            filePath = "../../../"+ filePath;
#endif
            var fileNameArray = new[] {
                "ascii.txt",
                "asciiWithChinese.txt",
                "gb18030.txt",
                "gb2312.txt",
                "gbk.txt",
                "utf8.txt",
                "utf8WithBOM.txt",
                "unicode.txt",
                "unicode-big-endian.txt"
            };
            for (int i = 0; i < fileNameArray.Length; i++)
            {
                var name = fileNameArray[i];
                var path = filePath + name;
                builder.AppendLine("文件名: " + name);
                builder.AppendLine("文本编码猜测："+TextCodeGuessHelper.GuessFileEncoding(path).EncodingName);
                builder.AppendLine("是否是纯ASCII: " + TextCodeGuessHelper.IsPlainASCII(path));
                builder.AppendLine("是GBK还是UTF8: " + TextCodeGuessHelper.IsGBKOrUTF8(path).EncodingName);
                builder.AppendLine();
            }
            var result = builder.ToString();
            Console.WriteLine(result);
        }
    }
}
